/* 
 * File:   SparseMatrixReport.h
 * Author: lsc
 *
 * Created on November 8, 2013, 3:03 PM
 */

#ifndef SPARSEMATRIXREPORT_H
#define	SPARSEMATRIXREPORT_H

#include "SkylineStorage.h"
#include <stdio.h>

template<class T>
class SparseMatrixReport{
    
    public:
        SparseMatrixReport(const SkylineStorage<T>&);
        void print();
        private:
            int m_dim;
            int nonzeros;
            int bandwidth;
            void setBandWidth(const SkylineStorage<T>&);
            void setNonZeros(const SkylineStorage<T>&);
            
};

template<class T>
SparseMatrixReport<T>::SparseMatrixReport(const SkylineStorage<T>& _M){
    m_dim = _M.getCols();
    setBandWidth(_M);
    setNonZeros(_M);
}



template<class T>
void SparseMatrixReport<T>::setBandWidth(const SkylineStorage<T>& _M){
int hi;
int I;
bandwidth = 0;
for(int i=1; i<m_dim; i++){
    hi = _M.P(i-1) - _M.P(i) + i + 1;
    I = _M.P(i) - i;
    if(abs(i-hi) > bandwidth)
        bandwidth = abs(i-hi);
}
}

template <class T>
void SparseMatrixReport<T>::setNonZeros(const SkylineStorage<T>& _M){
    nonzeros  = m_dim*m_dim;
    for(int i=0; i<m_dim;i++){
        for(int j=0; j<m_dim; j++){
            if(_M(i,j)==0){
                nonzeros--;
            }
        }
    }
}
template <class T>
void SparseMatrixReport<T>::print(){
    cout<< "BandWidht:" << bandwidth << endl   ;        
    cout<< "Non-zeros:" << nonzeros << endl   ;        
}

#endif



